package com.project.config;

import org.apache.ibatis.logging.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * mybatis-plus控制台输出配置
 *
 * @author Leo高洋
 * @create 2023-03-03 23:41
 */
public class SqlOutLogImpl implements Log {

    private final static Logger logger = LoggerFactory.getLogger(SqlOutLogImpl.class);

    public SqlOutLogImpl(String clazz) {
        logger.debug("SqlOutLogImpl::" + clazz);
        // System.out.println("SqlOutLogImpl::" + clazz);
    }

    @Override
    public boolean isDebugEnabled() {
        return true;
    }

    @Override
    public boolean isTraceEnabled() {
        return false;
    }

    @Override
    public void error(String s, Throwable throwable) {
        logger.error("Mybatis错误::" + s);
        // System.err.println(s);
        throwable.printStackTrace(System.err);
    }

    @Override
    public void error(String s) {
        logger.error("SqlOutLogImpl:Error: " + s);
        // System.err.println("SqlOutLogImpl:Error:" + s);
    }

    @Override
    public void debug(String s) {
        logger.debug("SqlOutLogImpl:Debug: " + s);
        // System.out.println("SqlOutLogImpl:Debug:" + s);
    }

    @Override
    public void trace(String s) {
        logger.trace("SqlOutLogImpl:Trace: " + s);
        // System.out.println("SqlOutLogImpl:Trace:" + s);
    }

    @Override
    public void warn(String s) {
        logger.warn("SqlOutLogImpl:Warn: " + s);
        // System.out.println("SqlOutLogImpl:Warn:" + s);
    }
}
